package com.simple.accounting.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

import com.simple.accounting.R;

public class SplashActivity extends BaseActivity {


    private int time = 1;
    private Handler handler = new Handler();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        handler.postDelayed(runnable, 500);
    }


    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            time--;
            handler.postDelayed(this, 500);
            if (time == 0) {
                goToNextActivity();
            }
        }

        private void goToNextActivity() {
            //结束线程
            handler.removeCallbacks(runnable);
            startActivity(new Intent(SplashActivity.this, LoginActivity.class));
            finish();
        }
    };
}
